Semantic Web • Week 01
Motivation, the layer architecture, the core concepts and an introduction to the term project
Graduate Semantic Web Course • CMPE 583 • A 10-Week Programme
Course Schedule
| Week | Topic | Contribution to the project |
|---|---|---|
| 01 | Introduction to the Semantic Web | Problem statement, toolchain setup |
| 02 | XML & XML Schema | Structuring the product data |
| 03 | RDF & RDFS | The triple model, the vocabulary |
| 04 | OWL Fundamentals | Class, Property, Individual |
| 05 | Advanced OWL & Protégé | Restriction, cardinality |
| 06 | OWL-S | The recommendation engine as a service |
| 07 | SWRL | 7 inference rules (S1–S7) |
| 08 | OWL API-I with Java | Building the ontology programmatically |
| 09 | OWL API-II & Reasoner | Inference with HermiT / Pellet |
| 10 | SWRL API & Final | The end-to-end working system |
Week 01 • Objectives
01
Today's Web was written for people. What would a Web written for machines look like?
HTML says how the content should look; it does not say what it means.
For the browser there is no type difference between "Nisin" and "36" — both are text nodes.
No software can answer the question "is this product risky for someone with a lactose allergy?" from this page.
HTML
<p>Nisin</p>
Presentation. Machine: "text".
XML
<katki>Nisin</katki>
Structure. Machine: "a field named katki".
OWL + SWRL
Nisin a FoodAdditives . Nisin Triggers Lactose .
Meaning. Machine: "it triggers a lactose allergy" → it can infer.
| Aspect | Traditional Web (Document Web) | Semantic Web (Data Web) |
|---|---|---|
| Basic unit | Page / document | Resource and triple |
| Link | Unnamed hyperlink | A relation with defined meaning (Triggers) |
| Where the meaning is | In the mind of the reader | Inside the model, formal |
| Access | Keyword search | Query + inference (SPARQL / SQWRL) |
| Integration | Manual mapping | Automatic, through shared IRIs |
| New knowledge | Written by a human | Produced by the reasoner and the rules |
Veri
"Nisin"
A symbol without context
Information
EAN_00004 Contain Nisin
Data placed in a context
Bilgi
Nisin Triggers Lactose
Relation + rule: inference becomes possible
Decision
PersonAtRisk(TC_001)
A conclusion that turns into action
Semantic Web technologies move the third step of this ladder to the machine; the fourth step is the job of the application layer.
| Question | Keyword search | Semantic system |
|---|---|---|
| "Products containing Nisin" | Works — text matching | Works |
| "Products that are risky for people with a lactose allergy" | Fails — "lactose" is not written on the label | Infers it from the additive → allergy trigger chain |
| "Is the product Ayse chose suitable for her?" | No personal profile information | The person profile and the product content are evaluated together |
The difference is not in the amount of data: what is missing is expressing the relations in a form a machine can interpret.
Term Project • Problem
Target behaviour of the system
User: has a lactose allergy, has chosen Eti Chocolate.
System: the product contains Nisin, Nisin triggers Lactose → risky.
| Barcode (individual) | Product name | Additives | Allergy triggered |
|---|---|---|---|
| EAN_00001 | ETI Cracker | Alginic_Acid | Gluten |
| EAN_00002 | Ulker Damak | Phospore, Soy_Lecitin | Egg |
| EAN_00003 | Dardanel Ton | Casein, Sodium_Ascorbite | Lactose, Fish |
| EAN_00004 | Eti Chocolate | Ascorbic_Acid, Nisin, Soy_Lecitin | Lactose, Egg |
The last column is not written on the label — it comes from the Triggers relation in the ontology.
The Semantic Web is an extension of the current Web in which information carries a meaning that machines can process.
Berners-Lee, Hendler & Lassila, The Semantic Web, Scientific American, 2001 — the idea in brief
Readable
Parsable syntax: CSV, JSON, XML. The machine sees the fields but does not know the relations.
{"katki":"Nisin"}
Understandable
A model with formal semantics: RDF/OWL. The machine infers the type, the restriction and the conclusion.
Nisin Triggers Lactose .
| Approach | Strength | Limit |
|---|---|---|
| Relational table | Speed, maturity | No off-schema relations, no inference |
| Concept map | Clear to a human | No formal semantics |
| Frame systems | Object-like modelling | No standard inference |
| Description logic (OWL) | Decidable inference, a standard | Limited expressiveness (no arithmetic) |
| Rule-based (SWRL) | Chaining, built-in arithmetic | The DL-safe restriction, for decidability |
Our project uses the last two rows together: the structure is modelled in OWL, the computation and the chaining in SWRL.
02
Every layer rests on the one below it: identification, syntax, data, vocabulary, logic, rules, queries.
The same ontology can be written in several serialisations. Our project file is in RDF/XML format.
Validation with XML Schema is covered in Week 02, and Turtle syntax in detail in Week 03.
Every arrow is a triple: subject – predicate – object. Triples join into a graph; walking over the graph produces new knowledge.
Inference example: Adult(TC_001) → Person(TC_001).
| Need | RDFS | OWL |
|---|---|---|
| Class hierarchy | Yes | Yes |
| Disjointness | No | owl:AllDisjointClasses |
| Restriction | No | someValuesFrom, allValuesFrom |
| Cardinality restriction | No | minCardinality |
| Equivalence / identity | No | equivalentClass, sameAs |
Projede Person, Product, FoodAdditives, Allergy are declared disjoint — an individual cannot be a product and a person at the same time.
SPARQL
The standard query language over an RDF graph (W3C).
SQWRL
A query language built on SWRL; it works over the output of the rules (Week 10).
OWL is strong in class definitions; but chaining several properties to produce a new relation and arithmetic lie outside OWL.
This rule is the core of the risk analysis in the project; it is covered in detail in Week 07.
Consistency
Does the ontology contain a contradiction? isConsistent()
Classification
Which class falls under which? The hidden hierarchy comes out.
Realisation
Of which classes is each individual a member? getTypes()
In the project HermiT does these three jobs; the SWRL rules are run by the Drools-based SWRL rule engine (Weeks 09–10).
| Layer | Counterpart in the project | Week |
|---|---|---|
| IRI | http://EMU/AllergyOntology# | 01 |
| XML | ALLERGY_FIXED.owl (RDF/XML) | 02 |
| RDF / RDFS | Triples, subClassOf, domain/range | 03 |
| OWL | 4 classes, 10 properties, disjoint classes, restrictions | 04–05 |
| Service | Description of the recommendation service with OWL-S | 06 |
| Rules | The SWRL rules S1–S7 | 07 |
| API | OWL API + SWRL API (Java, NetBeans) | 08–10 |
| Queries | SQWRL queries (Q1–Q3) | 10 |
03
Ontology, class, property, individual, axiom and inference.
A formal, explicit specification of a shared conceptualisation.
Formal
A machine can interpret it
Explicit
The concepts are written down
Shared
The community agrees on it
Conceptualisation
The abstract model of the domain
| Structure | Expressiveness | Food example |
|---|---|---|
| Term list | Names only | A list of additive names |
| Taxonomy | Sub/super relation | Additive → preservative → Nisin |
| Thesaurus | Synonyms, related terms | Casein ≈ milk protein |
| Ontoloji | Restrictions + logic + inference | "A product containing Nisin is risky for someone with a lactose allergy" |
Our project sits in the last row: thanks to restrictions and rules, the system produces knowledge that was never written down.
| Notion | Meaning | Example in the project |
|---|---|---|
| Class | A set of individuals | Person, Product, FoodAdditives, Allergy |
| Object Property | An individual → individual relation | Contain, Triggers, hasAllergy, ChooseProduct |
| Datatype Property | An individual → data value | hasAge, hasWeight, hasHeight, hasBMI, hasName |
| Individual | A concrete object | TC_001, EAN_00004, Nisin, Lactose |
| Axiom | A statement taken to be true | Adult ⊑ Person, disjointness of the classes |
The risk chain travels between these four classes: Person → Product → FoodAdditives → Allergy and back to Person.
This is how every entity is accessed on the Java side. Writing the namespace wrongly does not raise "class not found"; it silently returns an empty result — the most common mistake.
In an ontology, what is not written is not false; it is simply unknown.
This is why the conclusion "this product contains no allergen" can be inferred only if a closure axiom (e.g. a cardinality restriction) is added.
Example from the project
EAN_00001 Contain Alginic_Acid .
We are not saying that this product contains only Alginic_Acid. There may be other additives — this is simply not known yet.
Unless stated otherwise, two different IRIs may denote the same object. In the food domain this is not a rule but a fact: the same additive is called differently in different countries.
Without disjointness and difference axioms the reasoner says "they may be the same" and does not find the contradiction you expect.
| Aspect | Relational database (CWA) | Ontology (OWA) |
|---|---|---|
| Missing data | Ignored → false | Unknown |
| Schema | Prescriptive, it rejects data | Descriptive, it produces inferences |
| The same name | Key uniqueness | sameAs links them |
| New knowledge | Through INSERT | Through inference as well |
| Inconsistency | Constraint violation | A logical contradiction (found by the reasoner) |
A frequent mistake: building the ontology like a table and then asking "why is no inference coming?".
None of them was written into the file by hand; all three are products of the rule engine. This is the final output of the project.
04
A SWRL-based semantic packaged-food analysis and intelligent recommendation system.
Deliverable output
ALLERGY_FIXED.owl AllergyReasoner (Maven project) ALLERGY_INFERRED.owl console report
The eight-step flow Main.java is coded in exactly this order (STEP 1 … STEP 8).
Adult ve PersonAtRisk classes are never populated by hand; their members come from the rules.
Four allergen-specific properties (Egg_, Fish_, Gluten_, Lactose_Allergen) sit under a single super-property: Effected_Allergen.
| Property | Type | Source |
|---|---|---|
| hasName | string | by hand |
| hasAge | int | by hand |
| hasWeight | double | by hand |
| hasHeight | double | by hand |
| hasBMI | double | rule S4 |
There is no direct link between a product and an allergy; the link is made through the additive — the most important design decision of the model.
| Individual | Name | Age | Weight / Height | Allergy | Chosen product |
|---|---|---|---|---|---|
| TC_001 | Ayse | 38 | 67.5 / 1.68 | Lactose | EAN_00004 |
| TC_002 | FATMA | 13 | 84.6 / 1.73 | Lactose | EAN_00003 |
| TC_003 | MEHMET | 35 | 93.0 / 1.87 | Fish, Lactose | EAN_00003 |
| TC_004 | AYNUR | 54 | 91.0 / 1.65 | Egg, Gluten | EAN_00002 |
TC_002 is thirteen years old: rule S5 will Adult not infer Adult for him — the negative test case of that rule.
| Rule | Purpose | Knowledge produced |
|---|---|---|
| S1_FishRisk | Sodium Ascorbate → fish risk | Fish_Allergen |
| S2_LactoseCasein | Casein → lactose risk | Lactose_Allergen |
| S3_LactoseNisin | Nisin → lactose risk | Lactose_Allergen |
| S4_BMI | BMI computed from weight and height | hasBMI (built-in arithmetic) |
| S5_Adult | Age ≥ 18 | Adult |
| S6_GenericAllergen | The generic risk chain | Effected_Allergen |
| S7_RiskClass | Classify the affected person | PersonAtRisk |
| Person | w / h | Inferred BMI |
|---|---|---|
| TC_001 | 67.5 / 1.68 | 23.92 |
| TC_003 | 93.0 / 1.87 | 26.60 |
| TC_004 | 91.0 / 1.65 | 33.43 |
A schematic view — the tab names and the panel layout match a real Protégé session.
The orange rows are the ones added by the rule engine; Protégé shows inferred assertions in a different colour.
The order of the three buttons matters; this flow is shown in detail in Weeks 07 and 10.
The fact that PersonAtRisk list was empty before the rules and is now filled is the proof that the system works.
| Tool | Role | Note |
|---|---|---|
| Protégé 5.5+ | Editing the ontology and the rules | With the SWRLTab plugin |
| Java JDK 8 / 11 | Runtime environment | 8 is recommended for SWRL API compatibility |
| NetBeans | IDE | Maven project support |
| OWL API 4.x | Managing the ontology programmatically | A Maven dependency |
| SWRL API + Drools | Rule engine | swrlapi-drools-engine |
| HermiT / Pellet | Reasoner | Consistency and classification |
In Week 08 the pom.xml dependencies will be built line by line.
05
Week 01 deliverable: the working environment + a first concept map.
Deliverable
A 2–3 page PDF: screenshots, the product table, the proposed concept list (separated into class / property / individual).
A detailed solution of this assignment will be presented as a separate part at the end of Week 02.
| Criterion | Weight | Expected |
|---|---|---|
| Toolchain setup | 20% | Protégé + SWRLTab + JDK + NetBeans all work |
| Reading the ontology | 25% | The counts and roles of classes, properties and individuals are correct |
| Domain analysis | 35% | The additive → allergy mapping is justified |
| Concept distinction | 20% | Class and individual are not confused |
The most frequent mistake: Nisin modelling a concrete additive as a class.
Summary • 1 / 2
Summary • 2 / 2
In Week 02
XML & XML Schema: structuring the product data, validation with XSD and preparation for RDF/XML syntax.
Also: the detailed solution of Assignment 1.
Review Questions
Exercise • In class
A biscuit with Whey Protein ve Wheat Starch on its label is added to the ontology (EAN_00005).
The triples you will write (template)
EAN_00005 a Product . EAN_00005 Contain ________ . ________ a FoodAdditives . ________ Triggers ________ .
The solution will be given in the assignment-solution part of Week 02.